


import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:textfluttertimer/test_provider/timer_model.dart';

class TextProviderWidget extends StatefulWidget {
  @override
  State<StatefulWidget> createState() {
    return _TextProviderState();
  }

}

class _TextProviderState extends State<TextProviderWidget>{
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Center(
        child: Consumer<TimerModel?>(builder: (content,timerModel,_){
          return RaisedButton(
            onPressed: ()async{
              timerModel?.startTimer();
            },
            child: Text(
              timerModel?.count == 0? "获取验证码": '${timerModel?.count} 秒后重发',
              style: timerModel?.count == 0?
              TextStyle(color: Colors.blue,fontSize: 14):
              TextStyle(color: Colors.grey,fontSize: 14),
            ),
          );
        },),
      ),
    );
  }

}